package com.yitao.cms.controller.user.cmsUser;


import com.skipper.base.bean.DataOutput;
import com.yitao.cms.config.aopLog.LogAnnotation;
import com.yitao.cms.dto.operationUser.OperationPermissionDto;
import com.yitao.cms.service.user.cmsUser.OperationPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@Api(value = "permission", description = "资源模块")
@RestController
@RequestMapping("/permission")
public class OperationPermissionController {
    @Autowired
    private OperationPermissionService permissionService;


    @ApiOperation("菜单添加/修改")
    @LogAnnotation(targetType = "permission-updatePermission", remark = "菜单添加/修改")
    @RequestMapping(value = "/updatePermission", method = RequestMethod.POST)
    public DataOutput updatePermission(@RequestBody OperationPermissionDto permissionDto, HttpServletRequest request) {
        Assert.notNull(permissionDto,"参数不正确");
        return permissionService.updatePermission(permissionDto,request);
    }



    @ApiOperation("菜单列表")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public DataOutput permissionList() {
        return permissionService.permissionList();
    }

    @ApiOperation("菜单禁用")
    @LogAnnotation(targetType = "permission-delete", remark = "菜单禁用")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public DataOutput permissionDisable(Long permissionId) {
        return permissionService.permissionDeleteById(permissionId);
    }


}

